using IuliiaBot.Application.Commands;
using IuliiaBot.Application.Interfaces;
using Telegram.Bot.Types;
using Telegram.Bot.Types.Enums;

namespace IuliiaBot.Telegram.Commands;

public class TelegramCommandFactory : ICommandFactory<Update>
{
    public CommandBase GetCommand(Update update, ISander sander)
    {
        switch (update.Type)
        {
            case UpdateType.Message:
            {
                var message = update.Message!;

                switch (message.Type)
                {
                    case MessageType.Text:
                    {
                        if (message.Text == "/start")
                            return new InfoCommand(sander);
                        
                        var command = new TransliteCommand(sander);
                        command.SetMessage(message.Text ?? string.Empty);
                        return command;
                    }
                    default:
                    {
                        return new UnsupportedMessageCommand(sander);
                    }
                }
            }
        }
        return new UnsupportedMessageCommand(sander);
    }
}
